<template>
  <a-spin class="oncebutton" :spinning="spinning">
    <!-- @click="workchangeopen" -->
    <div class="ant-btn ant-btn-primary oncebuttondiv" :style="stylestr" @click="action">
      <span>{{ title }}</span>
    </div>
  </a-spin>
</template>

<script>
export default {
  name: 'Oncebutton',
  props: {
    title: {
      type: String,
      default: '',
    },
    fn: {
      type: Function,
    },
    fnparams: {
      type: String,
      default: '',
    },
    stylestr: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      spinning: false,
    }
  },
  methods: {
    action() {
      let that = this
      that.spinning = true
      // this.$emit('action', `${this.methodisname}`)
      that.fn(`${this.fnparams}`).finally((_) => {
        that.spinning = false
      })
    },
  },
  mounted() {
    // console.log(this.fn)
  },
}
</script>

<style lang="less" scoped>
.oncebutton {
  /deep/ .ant-spin.ant-spin-spinning {
    display: none;
  }
  .oncebuttondiv {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
</style>
